Let's get into the
details of microservices. Microservices are
modular, autonomous, and logical units of
functionality that are independently deployable
and scalable. The microservice architectural
style is an approach to developing a single application as a suite of small services, each running in its
own process and communicating with
lightweight mechanisms. Each microservice
focuses on completing only one task and does
that one task well. A task represents a small
business capability. Each microservice
communicates with another microservice through
an interface to solve business problems and with a UI micro-service to independently provide
service to the client. Now the advantages
of microservices are as follows; Modularity. Each microservice demonstrates
a logically cohesive, lightweight, and
independent business functionality with
well-defined boundaries. Single functionality principle. Each service encapsulates a single
business functionality. Asynchronous invocation. Microservices are
stateless by default, thereby helping us invoke
them asynchronously. Independent deployment
and scalability. Each microservice can be independently
deployed and hence, they are independently
scaled to respond to varying workloads
and user demands. Self containment. A microservice
deployment unit is self-contained as it includes
all dependent libraries, storage units, and databases. Fault tolerant. Microservices architecture eliminates single
points of failure through distribution of coherent functionality
among other services. Even if a single
service goes down, the application will
continue to work. By leveraging the
circuit breaker pattern, fault tolerance can
also be enhanced. Loose coupling. They are designed to be
loosely coupled with minimal dependencies on
other services in libraries. Well-defined communication
between services. Microservices communicate
with each other with well-defined
rest endpoints. Extensible, these can
be leveraged to create an extensible solution by
quickly onboarding newer ones. Multiple technology support. Each microservice can use
any technology independent of one another and
faster release cycles. Microservices can be
developed in parallel by multiple developers resulting
in reduced release time. Microservices also
have some challenges. They are; visibility. Individual services may be developed by different groups of app developers and may be introduced into the
application at anytime. Developers need a way to
discover services and their dependencies
automatically as soon as they are brought live. Bounded context. While dividing the application into multiple microservices, each microservice must include certain unique
functionalities. This can become challenging
as it is difficult to set the functional boundaries
of each microservice. Configuration management, each microservice has multiple instances in
different environments. In case of a larger application where the microservice
count is quite high, it can get troublesome for the operations team to
manage configurations. Dynamic scale up and scale down, the number of microservices required at different
points while running an application varies depending upon the requirement. In order to achieve
this flexibility, a microservice
architecture needs to be deployed for dynamic
load balancing. This setup can prove to
be a challenge in itself.